package com.itstyle.mytest.queue.jvm;

import com.itstyle.mytest.service.IMyTestService;
import com.itstyle.seckill.common.entity.SuccessKilled;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 消费秒杀队列
 * 创建时间	2018年4月3日
 */
@Component
public class MyTaskRunner implements ApplicationRunner{
	
	@Autowired
	private IMyTestService testService;
	@Override
    public void run(ApplicationArguments var) throws Exception{
		System.out.println("#########################################11111111111111111");

		while(true){
			System.out.println("#########################################$$$$$$$$$$$$$$$$$$$222");

			//进程内队列
			SuccessKilled kill = MySeckillQueue.getMailQueue().consume();
			//if(kill!=null){
				testService.startSeckil(kill.getSeckillId(), kill.getUserId());
			//}
		}
    }
}